<template>
	<view >
	
	  <view class="content">
	    <view class="tit">完善您的实名信息</view>
	    <view class="tit-text">请填写与您身份证一致的信息，否则不会通过审核</view>
	  </view>
	
	  <view class="input_wrap">
	    <view class="input_min">
	      <view class="input_tit">真实姓名</view>
	      <input class="input_con" v-model="userInfo.name" onInput="bindKeyInput" placeholder="请填写您本人的真实姓名" placeholder-class="placeholder-input" />
	    </view>
	
	    <view class="input_min">
	      <view class="input_tit">身份证号</view>
	      <input class="input_con" v-model="userInfo.idCard" onInput="bindIdInput" placeholder="请填写您本人的身份证号" placeholder-class="placeholder-input" />
	    </view>
	  </view>
	
	  <view class="bottom_zhan"></view>
	  
	  <view class="footer">
	    <view class="footer_top">
	      <image class="footer_top_icon" mode="scaleToFill" :src="$IMAGE_URL+'/anquan_icon.png'" />
	      <view class="footer_top_text">平台将智能加密，实施保障你的信息安全</view>
	    </view>
	    <button class="footer_btn footer_btnN" v-if="!userInfo.name || !userInfo.idCard" size="default" type="primary">确认并提交</button>
	    <button class="footer_btn" v-else size="default" type="primary" @tap="onsumclick">确认并提交</button>
	  </view>
	    
	</view>
</template>

<script>
	import { mapMutations, mapActions, mapState, mapGetters } from "vuex";
	export default {
		components: {},
		data() {
			return {
				btnShow:false,
				query: { id: '' },
				point:{},
				oid:''
			};
		},
		computed: {
			...mapGetters(["userInfo", "authType"])
		},
		onLoad() {
			console.log(this.userInfo)
		},
		created() {
			if (this.$Route.query.oid) {
				this.oid = this.$Route.query.oid;
				console.log("认证页面订单id",this.oid)
			}
		
		},
		// onBackPress(e) {
		// 	console.log('返回',e.from)
		// 	 uni.reLaunch({
		// 	         url: '/pages/index/user'
		// 	     })
		//       return true; //阻止默认返回行为
		//  },
	
		methods: {
			...mapActions(["getUserInfo"]),
			jump(path, parmas) {
			  this.$Router.push({
			    path: path,
			    query: parmas,
			  });
			},
			 onsumclick() {
				let _IDRe18 = /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
				let _IDre15 =  /^([1-6][1-9]|50)\d{4}\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}$/
				if(_IDRe18.test(this.userInfo.idCard) || _IDre15.test(this.userInfo.idCard)){
					this.userInfo.idCard = this.userInfo.idCard;
					this.btnShow = true;
					console.log("正常")
				}else {
					this.btnShow = false;
					this.$u.toast('请输入正确身份证号');
					return;
				}
				let _name = /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/
				if (!_name.test(this.userInfo.name)) {
					this.btnShow = false;
					this.$u.toast('请输入正确姓名');
					return
				 } else {
					 this.userInfo.name = this.userInfo.name,
					 this.btnShow = true;
				 }
				if (!this.userInfo.name || !this.userInfo.idCard) {
					this.$u.toast('请输入正确信息');
				};
				let data = {
					idCard: this.userInfo.idCard,
					name: this.userInfo.name,
					oid:this.oid
				};
				console.log('人脸识别参数',data)
				// this.$http("user.faceCertifyQuery",{certifyId:123})
				// 	.then(res => {
				// 		console.log('人脸结果',res)
				// 	});
				//人脸
				this.$http("user.authFace",data)
					.then(res => {
						console.log('人脸识别调起地址1',res)
						if(res.code != 200){
							this.$u.toast(res.msg);
							return ;
						}
						uni.navigateTo({ 
						  url: `/pages/public/webview?webviewPath=${encodeURIComponent(res.data.certify_url)}`
						});
						// // app跳转页面
						// // #ifdef H5 
						// window.location.href = res.data.certify_url;
						// // #endif
						
						// // #ifdef APP-PLUS
						//  plus.runtime.openURL(res.data.certify_url)
						// // #endif
					  //  plus.runtime.openURL(res.data.certify_url, function(res) {
							// console.log('app跳转页面返回参数',res);
					  //  });
						// this.$http(
						// 	"user.authSave",data,"保存中..."
						// )
						// .then(authSave => {
						// 	console.log(authSave)
						// 	this.getUserInfo();
						// 	uni.switchTab({
						// 		url: '/pages/index/user'
						// 	});

						// });
						// uni.startAPVerify({
						// 	url: res.url,
						// 	certifyId: res.certifyId,
						// 	success: function (res1) {
						// 		console.log('人脸识别结果',res1)
						// 		if (res1.resultStatus == 9000) {
						// 			this.$http(
						// 				"user.authSave",data,"保存中..."
						// 			)
						// 			.then(authSave => {
						// 				console.log(authSave)
						// 				this.getUserInfo();
						// 				uni.switchTab({
						// 					url: '/pages/index/user'
						// 				});
									
						// 			});
									
						// 		} else {
						// 			this.$u.toast('失败');
						// 		}
						// 	}
						// })
					
					});
				console.log(data)
		// 		const auth = await app.user.authFace(data)
		// 		console.log("authFace",auth);
		// 		const apv = await app.user.startAPVerify(auth.data);
		// 		console.log("apv",apv);
		// 		if(apv.resultStatus!=9000) return;
		
		// 		// 保存信息到缓存
		// 		let user = my.getStorageSync({ key: 'user' });
		// 		user.data.name = this.data.name;
		// 		user.data.idCard = this.data.idCard;
		// 		my.setStorageSync({key: 'user',data: user.data });
		
		// 		// 保存到服务器
		// 		const save = await app.user.authSave(data)
		// 		const human = await app.user.humanAuth(this.data.query.id)
		// 		console.log("保存用户信息",save)
		// 		console.log("更改订单状态",human)
		// 		my.reLaunch({ url: "/pages/order/orderList/orderList"});
			}

		}
	};
</script>

<style lang="scss">
	
	page {
	    background: #FFF;
	    position: relative;
	}
	
	
	
	.content{
	  padding-top: 48rpx;
	}
	.tit{
	  text-align: center;
	  font-size: 48rpx;
	  font-weight: bold;
	  color: #333333;
	  line-height: 66rpx;
	}
	.tit-text{
	  text-align: center;
	  font-size: 30rpx;
	  color: #767D8F;
	  line-height: 42rpx;
	  margin-top: 16rpx;
	}
	
	.input_wrap{
	  width: 654rpx;
	  padding-top: 138rpx;
	  margin: 0 auto;
	}
	.input_min{
	  width: 100%;
	  border-bottom: 2rpx solid #E4E5E9;
	  margin-bottom: 70rpx;
	  padding-bottom: 16rpx;
	}
	.input_tit{
	  font-size: 30rpx;
	  color: #767D8F;
	  line-height: 42rpx;
	}
	.input_con{
	  width: 100%;
	  height: 54rpx;
	  line-height: 54rpx;
	  margin-top: 24rpx;
	  padding-left: 0;
	  font-size: 40rpx;
	  font-weight: bold;
	  color: #333333;
	}
	.placeholder-input{
	  font-weight: 400;
	  color: #E4E5E9;
	}
	
	
	
	
	
	
	.bottom_zhan{
	  width: 100vw;
	  height: 270rpx;
	}
	.footer{
	  width: 100vw;
	  height: 250rpx;
	  background-color: #fff;
	  position: fixed;
	  bottom: 0;
	  left: 0;
	  z-index: 100;
	  box-sizing: border-box;
	  padding-top: 18rpx;
	}
	.footer_top{
	  width: 100%;
	  display: flex;
	  justify-content: center;
	  align-items: center;
	}
	.footer_top_icon{
	  width: 26rpx;
	  height: 30rpx;
	}
	.footer_top_text{
	  font-size: 24rpx;
	  color: #767D8F;
	  line-height: 34rpx;
	  margin-left: 8rpx;
	}
	.footer_btn{
	  width: 670rpx;
	  height: 88rpx;
	  padding: 0;
	  margin: 0;
	  background: linear-gradient(358deg, #ffbc31 0%, #ffbc31 100%);
	  border-radius: 10rpx;
	  margin: 24rpx auto 0;
	  font-size: 32rpx;
	  font-weight: bold;
	  color: #333;
	  line-height: 88rpx;
	  letter-spacing: 2rpx;
	  border: 0;
	  outline: 0;
	}
	.footer_btnN{
	  background: linear-gradient(352deg, #BBBBBB 0%, #CCCCCC 100%);
	}
</style>